import { DataSource } from 'typeorm';
import { Template } from './entity/template.entity';
import { TemplateCategory } from './entity/template-category.entity';
import { User } from './entity/user.entity';
import { FileEntity } from './entity/file.entity';
import { SysConfig } from './entity/sys_config.entity';
import { ChargeRecord } from './entity/charge_record.entity';
import { Category } from './entity/category.entity';
import { Order } from './entity/order.entity';
import { Work } from './entity/work.entity';
import { Collection } from './entity/collection.entity';
import { QrCodeEntity } from './entity/qrcode.entity';
import { CommonEntity } from './entity/common.entity';
import { ChatRoomEntity } from './entity/chat_room.entity';
import { UserFileEntity } from './entity/user_file.entity';
import { ChatSceneEntity } from './entity/chat_scene.entity';
import { ChatRoundEntity } from './entity/chat_round.entity';

export const EntityProviders = [
  {
    provide: 'CATEGORY_REPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(Category),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'TEMPLATE_REPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(Template),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'TEMPLATE_CATEGORY_REPOSITORY',
    useFactory: (dataSource: DataSource) =>
      dataSource.getRepository(TemplateCategory),
    inject: ['DATA_SOURCE'],
  },

  {
    provide: 'USER_REPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(User),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'FILE_REPOSITORY',
    useFactory: (dataSource: DataSource) =>
      dataSource.getRepository(FileEntity),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'SYS_CONFIG_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(SysConfig),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'CHARGE_RECORD_GREPOSITORY',
    useFactory: (dataSource: DataSource) =>
      dataSource.getRepository(ChargeRecord),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'ORDER_REPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(Order),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'WORK_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(Work),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'COLLECTION_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(Collection),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'QRCODE_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(QrCodeEntity),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'COMMON_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(CommonEntity),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'CHAT_ROOM_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(ChatRoomEntity),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'USER_FILE_REPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(UserFileEntity),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'CHAT_SCENE_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(ChatSceneEntity),
    inject: ['DATA_SOURCE'],
  },
  {
    provide: 'CHAT_ROUND_GREPOSITORY',
    useFactory: (dataSource: DataSource) => dataSource.getRepository(ChatRoundEntity),
    inject: ['DATA_SOURCE'],
  },
];
